<!--#include virtual="/dzps/p1.asp"-->
<!DOCTYPE html>
<html>
<head>
  <title>用户管理</title>
<%
easp.include "h.asp"
' t_define
%>
</head>
<body>
  <div class="layui-fluid">
    <div class="layui-card">
      <div class="layui-form layui-card-header layuiadmin-card-header-auto">
        <div class="layui-form-item">
          <div class="layui-inline">
            <label class="layui-form-label">用户名</label>
            <div class="layui-input-block">
              <input type="text" name="username" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
          </div>

          <div class="layui-inline">
            <button class="layui-btn layuiadmin-btn-useradmin" lay-submit lay-filter="user-front-search">
              <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
            </button>
			  <button type="button" class="layui-btn layui-btn-normal" lay-submit lay-filter="del_seluser">删除所选</button>			
          </div>
        </div>
      </div>
      <div class="layui-card-body">
		<script type="text/html" id="barDemo">
			<a class="layui-btn layui-btn-xs" lay-event="editpass">密码初始化</a>
			<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del_user">删除</a>
			<a class="layui-btn layui-btn-xs" lay-event="modi">修改</a>
			<a class="layui-btn layui-btn-xs" lay-event="access_dbs">权限</a>
		</script>
		<table id="user-manage" lay-filter="user-manage"></table>
			<br>
      </div>
    </div>
  </div>

  <script src="/dzps/src/layuiadmin/layui/layui.js"></script>  
  <script>
  layui.config({
    base: '/dzps/src/layuiadmin/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'useradmin', 'table'], function(){
    var $ = layui.$
    ,form = layui.form
    ,admin = layui.admin	
    ,table = layui.table;
	
    var $ = layui.$,
    active = {
        reload: function() {
            var demoReload = $('#demoReload');
            table.reload('testReload', {
                where: {
                    key: {
                        id: demoReload.val()
                    }
                }
            });
        }
    };	
    form.render();
	table.render({
        elem: '#user-manage',
        url: layui.setter.base + 'lib/reg.asp?action=user',
        cols: [[
		{type:'checkbox'},		
        {field: 'id',title: 'ID',width: 60,sort: true,hide:true},
        <%g_tbf "user_typ,is_duty","用户类型,是否激活"%>
        {field: 'username',title: '用户名',width: 120},	
        {field: 'password',title: '密码',width: 120},		
        {field: 'iden',title: '身份证号',width: 120},		
        {field: 'mobile',title: '手机号',width: 120},		
        {field: 'trueName',title: '真实姓名',width: 120},		
        {fixed: 'right',width: 260,align: 'center',toolbar: '#barDemo'}]],
        id: 'user-manage',
        limit: 10,
        page: true,
        height: 475
    });
    form.on('submit(user-front-search)', function(data){
      var field = data.field;
      table.reload('user-manage', {
        where: field
      });
            layer.msg('已重载');	  
    });
  
    form.on('submit(del_seluser)', function(data){
      var field = data.field;
        var checkStatus = table.checkStatus('user-manage')
        ,data = checkStatus.data;
		
		layer.confirm('您确定删除选中行？' , {
				icon: 3,
				title: '提示信息'
			},				function(index) {	
		$.ajax({
		  type: "post",
		  url: 'pjson.asp?action=del_seluser',
		  data:JSON.stringify(data),
		  dataType: 'json',
		  success: function (data) {
		  }
		});
				layer.close(index);
				table.reload('user-manage');		
		});
    });  
    table.on('tool(user-manage)',
    function(obj) {
        var data = obj.data;
        if (obj.event === 'access_dbs') {
			layer.open({
			  type: 2,
			  title: '权限管理',
			  shadeClose: true,
			  shade: false,
			  maxmin: true, //开启最大化最小化按钮
			  area: ['893px', '600px'],
			  content: 'qx.asp?usernameqx='+data.username
			});
        }
		else if (obj.event === 'del_user'){
			var _this = $(this);
			layer.confirm('您确定删除该用户？', {
				icon: 3,
				title: '提示信息'
			},
			function(index) {
				$.post(layui.setter.base + 'lib/reg.asp?now=' + new Date().getTime(), {
					id: data.id,
					action: "del_user"
				},
				function(data) {
					if (data == '1') {
						layer.msg("成功!!");
					} else {
						layer.msg("失败！！ "+data);
					}
				});
				layer.close(index);
				table.reload('user-manage');				
			});
		}
		else if(obj.event === 'modi'){
			  layer.open({
				type: 2,title: '用户管理',content: 'user_frm.asp?now=' + new Date().getTime() +"&id="+data.id
				,maxmin: true
				,area: ['370px', '350px']
				,btn: ['确定', '取消']
				,yes: function(index, layero){
				  var iframeWindow = window['layui-layer-iframe'+ index]
				  ,submitID = 'LAY-user-front-submit'
				  ,submit = layero.find('iframe').contents().find('#'+ submitID);
				  iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
					var field = data.field; 
						$.post(layui.setter.base + 'lib/reg.asp?now=' + new Date().getTime(), {
							action: "user_edit",
							field
						},
						function(data) {
							layer.msg($.parseJSON(data).msg);
						});
					table.reload('user-manage'); 
					layer.close(index); 
				  });  
				  submit.trigger('click');
				}
				,success: function(layero, index){
				}
			  });	
			}
		else if (obj.event === 'editpass'){
			var _this = $(this);
			layer.confirm('您确定把该用户‘'+data.username+'’的密码初始化为 000000 ？', {
				icon: 3,
				title: '密码初始化提示'
			},
			function(index) {
				$.post(layui.setter.base + 'lib/reg.asp?now=' + new Date().getTime(), {
					id: data.id,
					username:data.username,
					iden:data.iden,
					trueName:data.trueName,
					action: "editpass"
				},
				function(data) {
					if (data == '1') {
						layer.msg("成功!!");
					} else {
						layer.msg("失败！！ "+data);
					}
				});
					layer.close(index);
					table.reload('user-manage');				
				});
		}		
	});	
    $('.layui-btn.layuiadmin-btn-useradmin').on('click', function(){
      var type = $(this).data('type');
      active[type] ? active[type].call(this) : '';
    });
  });
  </script>
</body>
</html>